#include <iostream>
#include <vector>
using namespace std;

class Vehicle {
public:
  virtual void move(void) = 0;
};

class Car: public Vehicle {
  virtual void move(void) {cout<<"Car::move()"<<endl;}
};

class Rocket:public Vehicle {
  virtual void move(void) {cout<<"Rocket::move()"<<endl;}
};

int main(int argc, char *argv[]){
  vector<Vehicle*> v;
  vector<Vehicle*>::iterator iter;
  
  Vehicle *v0 = new Car();
  Vehicle *v1 = new Rocket;
  Vehicle *v2 = new Car;
  v.push_back(v0);
  v.push_back(v1);
  v.push_back(v2);

  for(iter = v.begin();iter!=v.end();++iter){
    (*iter)->move();
  }
 //  vector<Vehicle> v;
//   vector<Vehicle>::iterator iter;
//   Car c0,c1;
//   Rocket r0;
//   Vehicle& v0 = c0;
//   Vehicle& v1 = r0;
//   Vehicle& v2 = c1;

//   v.push_back(v0);
//   v.push_back(v1);
//   v.push_back(v2);
//   for(iter = v.begin();iter!=v.end();++iter)
//     (*iter).move();

  Car c0,c1;
  Rocket r0;
  Vehicle& ve0 = c0;
  Vehicle& ve1 = r0;
  Vehicle& ve2 = c1;
  ve0.move();
  ve1.move();
  ve2.move();
  return 0;
}
